<?php
header("content-type:text/html;charset=utf-8");
$dsn="mysql:host=127.0.0.1;dbname=book;charset=utf8";
$pdo=new PDO($dsn,'root','root');
$sql="select * from qg";
$res=$pdo->query($sql);
$data=$res->fetchAll(PDO::FETCH_ASSOC);
$starttime=$data[0]['starttime'];
$starttime=strtotime($starttime);
$time=$starttime-time();
$hour=floor($time/3600);
$min=floor(($time-$hour*3600)/60);
$hour=$time-$hour*3600-$min*60;
echo json_encode(array('hour'=>$hour,'min'=>$min,'sec'=>$sec));
?>